const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sp_category', {
    cat_id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "分类唯一ID"
    },
    cat_name: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "分类名称"
    },
    cat_pid: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "分类父ID"
    },
    cat_level: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "分类层级 0: 顶级 1:二级 2:三级"
    },
    cat_deleted: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "是否删除 1为删除"
    },
    cat_icon: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    cat_src: {
      type: DataTypes.TEXT,
      allowNull: true
    }
  }, {
    sequelize,
    tableName: 'sp_category',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "cat_id" },
        ]
      },
    ]
  });
};
